//
//  dataStorage.m
//  testDataStore
//
//  Created by gzw on 12-10-21.
//  Copyright (c) 2012年 gzw. All rights reserved.
//

#import "dataStorage.h"

#define kFilepath @"/filepath/file.plist"

@implementation dataStorage

- (id)init
{
    self = [super init];
    if (self)
    {
       // dataArray = [[NSMutableArray alloc] init];
    }
    return self;
}

- (void)initDataArray
{

    
    NSString * str = @"hello data~";
    dataArray = [[NSMutableArray alloc] init];
    [dataArray insertObject:str atIndex:0];
}

- (void)readToDataArray
{
    NSString *applicationDocumentsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    
    NSString *storePath = [applicationDocumentsDir stringByAppendingPathComponent:@"myfile.txt"];
    
    dataArray = [NSArray arrayWithContentsOfFile:storePath];
}

- (void)writeFromDataArray
{
    NSString *applicationDocumentsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    
    NSString *storePath = [applicationDocumentsDir stringByAppendingPathComponent:@"myfile.txt"];

    
    [dataArray writeToFile:storePath atomically:YES];
    
}

- (void)dealloc
{
}

@end
